﻿using System;

namespace ZyGame
{
    public sealed class IntVarable : Varable<int>
    {
        public IntVarable(int value)
        {
            this.value = value;
        }

        public static implicit operator int(IntVarable varable)
        {
            return varable.value;
        }

        public static explicit operator IntVarable(int varable)
        {
            return new IntVarable(varable);
        }

        public static IntVarable operator +(IntVarable left, IntVarable right)
        {
            left.value = Math.Clamp(left.value + right.value, int.MinValue, int.MaxValue);
            return left;
        }

        public static IntVarable operator -(IntVarable left, IntVarable right)
        {
            left.value = Math.Clamp(left.value - right.value, int.MinValue, int.MaxValue);
            return left;
        }

        public static IntVarable operator *(IntVarable left, IntVarable right)
        {
            left.value = Math.Clamp(left.value * right.value, int.MinValue, int.MaxValue);
            return left;
        }

        public static IntVarable operator /(IntVarable left, IntVarable right)
        {
            left.value = Math.Clamp(left.value / right.value, 0, int.MaxValue);
            return left;
        }

        public static bool operator ==(IntVarable left, IntVarable right)
        {
            return left.value == right.value;
        }

        public static bool operator !=(IntVarable left, IntVarable right)
        {
            return left.value != right.value;
        }
    }
}
